home *** CD-ROM | disk | FTP | other *** search
/ 10,000 Great Games / 10,000 Great Games.iso / Product / 66 / data1.cab / Source_Files / Src / BHole.cpp < prev    next >
C/C++ Source or Header  |  2000-01-16  |  926b  |  55 lines

  1. #include "stdafx.h"
  2.  
  3. cBlackHole::cBlackHole(int _x, int _y, cProperties *_orig)
  4.         : cWeapon(_x, _y, _orig, "MOVING")
  5. {     
  6.     active = FALSE;
  7. }
  8.  
  9. cBlackHole::~cBlackHole()
  10. {    
  11. }
  12.  
  13. void cBlackHole::attract_all(cGameObject *l)
  14. {
  15.     for (; l != 0; l = (cGameObject *)l->next)
  16.         if (l != this && l->influenced_by_black_hole)
  17.             l->new_angular_push(0.2, 0, BLACK_HOLE_STRENGTH, angle(x - l->x, y - l->y));
  18. }            
  19.  
  20. int cBlackHole::control()
  21. {
  22.     cWeapon::control();
  23.     
  24.     bounce_on_boundaries();
  25.     
  26.     // Check if we were hit
  27.     
  28.     if (explode)
  29.     {
  30.         // If we were not active before, set animation
  31.  
  32.         if (!active)
  33.         {
  34.             set_sequence("ACTIVE", TRUE);
  35.  
  36.             active = TRUE;
  37.         }
  38.  
  39.         // Push things around every fifth second
  40.  
  41.         if (!push_wait)
  42.         {
  43.             attract_all(weapons);        
  44.             attract_all(bonus);
  45.             attract_all(parts);
  46.  
  47.             push_wait = sec / 5;
  48.         }
  49.     }    
  50.     
  51.     // Delete when off screen
  52.     
  53.     return !in_water();
  54. }
  55.